#include "Command/Command.hpp"
#include <fstream>
using namespace std;


Command::Command()
: m_undoable(false)
{
}

//LoadDataCommand
LoadDataCommand::LoadDataCommand(char *path)
{
    m_path = path;
    m_undoable = false;
}

void LoadDataCommand::execute()
{
    CurveData *res = new CurveData();
    ifstream fin;
    fin.open (m_path, ifstream::in);
    res->load(fin);
    fin.close();
    MainControl::addCurveData(res);
}

void LoadDataCommand::unexecute()
{
}

//GetValue
GetValueCommand::GetValueCommand(double x, CurveData *data)
{
    m_x = x;
    m_data = data;
    m_undoable = false;
}

void GetValueCommand::execute()
{
    MainControl::updateCurveValue(m_data->curve(m_x));
}

